<?php 
class IndexController{
	function index(){
		include(ROOT."view/admin/tpl/index.html");
	}

	//左侧
	function left(){
	
		$rbac = new RbacModel();
		$node = new NodeModel();
		$message = new MessageTool();
		$_SESSION['uname']=isset($_SESSION['uname'])?$_SESSION['uname']:" ";
		$role = $rbac->selectRole($_SESSION['uname']);
		if($role['name'] == "Admin"){
			$arr = $node->findAllBySort();
			$row = $node->getstructure($arr);
		}else{
			$arr = $rbac->selectNode($role['role_id']);
			if(!empty($arr)){
				$row = $node->getstructure($arr,$arr[0]['pid']);
			}
			else{
				$msg = "对不起，暂时没为您分配权限";
				include(ROOT."view/admin/tpl/msg.html");
				exit;
			}
		}
		
        include(ROOT.'./view/admin/tpl/left.html');
		
	}

	//右侧
	function right(){
		$os = $this->get_os();
		$mysqlinfo=mysql_get_server_info();
		$php = phpversion();
		include(ROOT.'./view/admin/tpl/main1.html');
	}

    //上部
	function top(){
		$time = time();
		$date = date('Y年m月d日',$time);
		$weekarray=array("日","一","二","三","四","五","六");
		$week = "星期".$weekarray[date("w")];
		$current = $date."&nbsp;&nbsp; ".$week; 
		include(ROOT.'view/admin/tpl/top.html');
	}

	//操作系统
    public function get_os(){
    	$agent = $_SERVER['HTTP_USER_AGENT'];//获取操作系统，浏览器等信息
    	$os = '';
    	if(preg_match('/win/i', $agent) && preg_match('/nt 6.2/i', $agent))
		{
			$os = 'Windows 8';
		}
		else if(preg_match('/win/i', $agent) && preg_match('/nt 6.1/i', $agent))
		{
			$os = 'Windows 7';
		}
		else if(preg_match('/win/i', $agent) && preg_match('/nt 6.0/i', $agent))
		{
			$os = 'Windows Vista';
		}
		else if(preg_match('/win/i', $agent) && preg_match('/nt 5.2/i', $agent))
		{
			$os = "Windows 2003"; //preg_match字符串比对
		}
		else if(preg_match('/win/i', $agent) && preg_match('/nt 5.1/i', $agent))
		{
			$os = 'Windows XP';
		}
		else if(preg_match('/win/i', $agent) && preg_match('/nt 5/i', $agent))
		{
			$os = 'Windows 2000';
		}
		else if(preg_match('/win/i', $agent) && preg_match('/nt/i', $agent))
		{
			$os = 'Windows NT';
		}
		else if(preg_match('/linux/i', $agent))
		{
			$os = 'Linux';
		}
		else if(preg_match('/unix/i', $agent))
		{
			$os = 'Unix';
		}
		else if(preg_match('/sun/i', $agent) && preg_match('/os/i', $agent))
		{
			$os = 'SunOS';
		}
		else if(preg_match('/ibm/i', $agent) && preg_match('/os/i', $agent))
		{
			$os = 'IBM OS/2';
		}
		else if(preg_match('/Mac/i', $agent) && preg_match('/PC/i', $agent))
		{
			$os = 'Macintosh';
		}
		else if(preg_match('/PowerPC/i', $agent))
		{
			$os = 'PowerPC';
		}
		else if(preg_match('/AIX/i', $agent))
		{
			$os = 'AIX';
		}
		else if(preg_match('/HPUX/i', $agent))
		{
			$os = 'HPUX';
		}
		else if(preg_match('/NetBSD/i', $agent))
		{
			$os = 'NetBSD';
		}
		else if(preg_match('/BSD/i', $agent))
		{
			$os = 'BSD';
		}
		else if(ereg('/OSF1/i', $agent))
		{
			$os = 'OSF1';
		}
		else if(ereg('/RIX/i', $agent))
		{
			$os = 'IRIX';
		}
		else if(preg_match('/FreeBSD/i', $agent))
		{
			$os = 'FreeBSD';
		}
		else if(preg_match('/teleport/i', $agent))
		{
			$os = 'teleport';
		}
		else if(preg_match('/flashget/i', $agent))
		{
			$os = 'flashget';
		}
		else if(preg_match('/webzip/i', $agent))
		{
			$os = 'webzip';
		}
		else if(preg_match('/offline/i', $agent))
		{
			$os = 'offline';
		}
		else
		{
			$os = 'Unknown';
		}
    	return $os;
    }
}
 ?>